<html>

<body>
	<?php
include('class.php');
session_start();
$y=$_POST['year'];
$m=$_POST['month'];
$time = time();
$date = getdate($time);
$year = $date["year"];
$mon = $date["mon"];
$day = $date["mday"];
if($m>$mon){
    $age=$year-$y-1;
}
else $age=$year-$y;

	 function uploadFile()
		 {
			 //print_r($_FILES);
			 if(1)
			 {
				 if($_FILES["file"]["error"]>0)
				 {
					 echo "error";
					 return "upload/default.jpg";
				 }
				 else
				 {
					 move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" .$_FILES["file"]["name"]);
					 return "upload/" .$_FILES["file"]["name"];
				 }
			 }
			 else
			 {
				 echo "wrong";
				 return "upload/default.jpg";
			 }

		 }
		 if($_POST)
		 {
			$db=New DB();
			 $image=uploadFile();
			 $_POST['image']=$image;
			 $_SESSION['newid']=$db->addStaff();
             $id=$_SESSION['newid'];
             $db->addStaffbirth($id,$age);
             $db->close();
             echo '<script>
			 alert("Your login ID is: '.$id.', please remenber it carefully");
			 </script>';
			 
			 Header('Refresh: 0.001;url=Login.html');
         }

?>



</body>

</html>
